package com.whosly.rapid.data.resp.pojo.response;

import com.whosly.api.constant.Constants;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * 正常相应实体列表
 *
 * @author yueny(yueny09@163.com)
 * @param <T>
 *            返回数据类型
 * @date 2015年10月19日 上午10:10:27
 */
public class ListResponse<T> extends BaseResponse {

	/**
	 *
	 */
	private static final long serialVersionUID = 6775762668373162675L;

	/**
	 * 请求返回数据
	 */
	@Getter
	@Setter
	private List<T> data;

	public ListResponse() {
		super();
	}

	public ListResponse(String code, String message, List<T> data) {
		super(code, message);
		this.data = data;
	}

	public static ListResponse success() {
		return success("");
	}

	public static ListResponse success(String message) {
		return success(message, null);
	}
	public static <T> ListResponse<T> success(List<T> data) {
		return success("操作成功", data);
	}

	public static <T> ListResponse<T> success(String message, List<T> data) {
		return new ListResponse(Constants.SUCCESS, message, data);
	}

	public static ListResponse failure(String code, String message) {
		return failure(code, message, null);
	}

	public static <T> ListResponse<T> failure(String code, String message, List<T> data) {
		return new ListResponse<>(code, message, data);
	}
}
